#include <string>
#include <vector>
#include "rule.h"
#include "features.h"

using namespace std;

extern unsigned int UniqId;

rule::rule(string lhs, vector<string> rhs, class features *sem)
{
  Id=UniqId++;
  Lhs=lhs;
  Rhs=rhs;
  Sem=sem;
};

void
rule::print(ostream& out_stream)
{
  unsigned int i;
  out_stream << "(" << Lhs << " -> "; 
  bool first=true;
  for(i=0; i<Rhs.size(); i++){
    if (first)
      first=false;
    else
      out_stream << " ";
    out_stream << Rhs[i];
  }
  if (Sem){
    out_stream << ",";
    Sem->print(out_stream);
  }  out_stream << ")";
}

/***
string
rule::toString()
{
  string result;
  unsigned int i;
  result = Lhs + " -> "; 
  bool first=true;
  for(i=0; i<Rhs.size(); i++){
    if (first)
      first=false;
    else
      result += " ";
    result += Rhs[i];
  }
  result += Sem->print();
  return result;
}
***/
